﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace MD5_Trie_Demo
{
    public static class MD5Extentions
    {
        public static string CalcMD5Hash(this string str)
        {
            byte[] hashData = Encoding.UTF8.GetBytes(str).CalcMD5Hash();
            string hashStr = string.Join(string.Empty, hashData.Select(x => x.ToString("x2")));
            return hashStr;
        }

        public static byte[] CalcMD5Hash(this byte[] data)
        {
            using MD5 md5 = MD5.Create();
            byte[] hashData = md5.ComputeHash(data);
            return hashData;
        }
    }
}
